home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / PCI Driver Development Kit / • Tools / Utility / LogLibrary 950622 / LogDCMDSrc / dcmd_Includes / Dcmd.h next >
Encoding:
C/C++ Source or Header  |  1996-08-20  |  7.2 KB  |  182 lines  |  [TEXT/MPS ]

  1. /*    dcmd.h
  2.     This is the dcmd interface.
  3.     Copyright © 1988, 1994 Apple Computer, Inc.  All Rights Reserved.
  4. */
  5.  
  6. #ifndef __dcmd__
  7. #define __dcmd__
  8.  
  9. #include <Types.h>
  10. #include <MachineExceptions.h>
  11.  
  12. // Possible requests from the debugger to the command
  13.  
  14. enum
  15. {
  16.     dcmdInit            = 0,    // Initialize the Dcmd
  17.     dcmdDoIt            = 1,    // Normal Dcmd execution
  18.     dcmdHelp            = 2,    // Display help for Dcmd
  19.  
  20.     // Requests added to MacsBug in 6.5d10 that are only sent to version 3 or newer dcmds.
  21.  
  22.     dcmdSecondaryInit    = 3,    // Second time to init after all System patches have been loaded
  23.     dcmdShutdown        = 4,    // Dcmd should remove any patches (if possible)
  24.     dcmdGetInfo            = 5        // Return dcmd version and pointer to help text
  25. };
  26.  
  27.  
  28. // Register file indices
  29.  
  30. #define D0Register 0
  31. #define D1Register 1
  32. #define D2Register 2
  33. #define D3Register 3
  34. #define D4Register 4
  35. #define D5Register 5
  36. #define D6Register 6
  37. #define D7Register 7
  38.  
  39. #define A0Register 8
  40. #define A1Register 9
  41. #define A2Register 10
  42. #define A3Register 11
  43. #define A4Register 12
  44. #define A5Register 13
  45. #define A6Register 14
  46. #define A7Register 15
  47.  
  48. #define PCRegister 16
  49. #define SRRegister 17        // SR is only 16 bits and is stored in the high word
  50.  
  51.  
  52. // Heap block types
  53.  
  54. #define freeBlock             0
  55. #define nonrelocatableBlock 1
  56. #define relocatableBlock    2
  57.  
  58.  
  59. // Structure used to pass information to and from dcmds.
  60.  
  61. typedef struct
  62. {
  63.     long                    *registerFile;    // pointer to 68K CPU register set
  64.     short                    request;        // what action we are requested to take
  65.     Boolean                    aborted;        // Set to true if the user types a key while scrolling
  66.     unsigned long            macsBugVersion;    // version of MacsBug we are running under
  67.     short                    maxCallback;    // maximum valid callback we can make
  68.     unsigned char            currentISA;        // ISA of current PC
  69. #if 0
  70.     ExceptionInformation    *theException;    // Pointer to PowerPC machine state if ISA is PowerPC    
  71. #else
  72.     ExceptionInformationPowerPC *theException; // For PCI CIncludes
  73. #endif
  74.     Ptr                        requestIOBlock;    // general-purpose input/output data block pointer
  75. } dcmdBlock;
  76.  
  77. typedef struct
  78. {
  79.     Str255        usageStr;
  80.     Str255        creditsStr;
  81.     NumVersion    dcmdVersion;
  82. } GetInfoRequestBlock;
  83. typedef GetInfoRequestBlock *GetInfoRequestBlockPtr;
  84.  
  85. // Debugger routines that can be called by the command
  86.  
  87.   /* Draw the text in the Pascal string as one or more lines separated by CR's.
  88.      Each line causes the MacsBug display to be scrolled and the new line to be
  89.      drawn at the bottom. If the user types a key while scrolling then the aborted
  90.      flag is set telling the command to terminate immediately. */
  91.   pascal void dcmdDrawLine(const Str255 str);
  92.  
  93.   /* Draw the text in the Pascal string as a continuation of the current line.
  94.        CR's are not given special treatment. */
  95.   pascal void dcmdDrawString(const Str255 str);
  96.  
  97.   /* Draw a given number of characters starting from the given pointer as a 
  98.        continuation of the current line. CR's are not given special treatment. */
  99.   pascal void dcmdDrawText(StringPtr text, short length);
  100.  
  101.   /* Scrolls the MacsBug display up one line leaving a blank line at the bottom. */
  102.   pascal void dcmdScroll();
  103.  
  104.   /* Display the Pascal string in the command line area and wait for a key to be pressed.
  105.      Return TRUE if the user typed Return. All other keys return FALSE. MacsBug saves this
  106.      key and adds it to the command line once the current command completes. Typing any
  107.      key other than Return sets the aborted flag and tells the command to terminate immediately. */
  108.   pascal Boolean dcmdDrawPrompt(const Str255 str);
  109.  
  110.   /* Get the current command line position */
  111.   pascal short dcmdGetPosition();
  112.         
  113.   /* Set the current command line position. This should only be set to a value returned 
  114.      by dcmdGetPosition. */
  115.   pascal void dcmdSetPosition(short pos);
  116.  
  117.   /* Return the next character on the command line or CR if the entire line has been scanned */
  118.   pascal short dcmdGetNextChar();
  119.         
  120.   /* Return the next character on the command line or CR if the entire line has been scanned.
  121.      However, the current command line position is not changed. */
  122.   pascal short dcmdPeekAtNextChar();
  123.  
  124.   /* Copy all characters from the command line to the parameter string until a delimiter
  125.      is found or the end of the command line is reached. A delimiter is either a space,
  126.      a comma or a CR. Both single and double quoted strings are allowed on the command
  127.      line. However, the leading and trailing quotes must be of the same type. The parameter
  128.      string is returned without the quotes. This function returns the delimiter */
  129.   pascal short dcmdGetNextParameter(Str255 str);
  130.  
  131.   /* Parse the command line for the next expression. All expressions are evaluated to 32 bits.
  132.      This function returns the delimiter after the expression. The possible delimiters are
  133.      space, comma and CR.  Space is    not treated as a delimiter in the middle of expressions.
  134.      For instance, '1 + 2' will return    a value of 3 and the delimiter will be the char following
  135.      the 2. The return parameter 'ok' tells if the expression was parsed successfully. */
  136.   pascal short dcmdGetNextExpression(long* value, Boolean* ok);
  137.  
  138.   /* Copy the break message MacsBug displayed the last time it was entered into str.
  139.      This may contain multiple lines separated by CR's.*/
  140.   pascal void dcmdGetBreakMessage(Str255 str);
  141.         
  142.   /* Return a symbolic representation for address in str. If no symbol can be found
  143.      then an empty string is returned. The format of the symbol returned is Name+0000.
  144.      With the new compilers, the name is no longer restricted to 8 characters. */
  145.   pascal void dcmdGetNameAndOffset(long address, Str255 str);
  146.  
  147.   /* Return the trap name for the trap number. If no symbol can be found
  148.      then an empty string is returned. */
  149.   pascal void dcmdGetTrapName(short trapNumber, Str255 trapName);
  150.  
  151.   /* Return a pointer the macro name for the given value. If no macro can be found
  152.      then a nil is returned. */
  153.   pascal StringPtr dcmdGetMacroName(long value);
  154.  
  155.   /* When a debugger command is called, the debugger's world (low memory) is installed.
  156.      Commands that want to reference the user's world can swap back and forth between the
  157.      two worlds by making this call. This procedure does nothing in MacsBug. It is included
  158.      to support other debuggers that might want to take advantage of it. */
  159.   pascal void dcmdSwapWorlds();
  160.  
  161.   /* Toggle between the user and debugger displays.
  162.      The first call restores the user's actual screen.
  163.      The second call restores the debugger's screen. */
  164.   pascal void dcmdSwapScreens();
  165.  
  166.   /* Walk thru the blocks in the current heap, calling DoThis for each block. DoThis should
  167.      be a procedure of the form:
  168.                 
  169.         pascal void DoThis (long blockAddress, long blockLength, long addrOfMasterPtr,
  170.                              short blockType, Boolean locked, Boolean purgeable, Boolean resource)
  171.  
  172.      The blockAddress and blockLength pertain to the data in the heap block, not including
  173.      the block header. The addrOfMasterPtr is the master pointer's location in the heap,
  174.      not the value of the master ptr. The blockType is defined by the constants freeBlock,
  175.      nonrelocatableBlock and relocatableBlock. The booleans locked, purgeable and resource
  176.      reflect the state of the block.    */
  177.   typedef pascal void (*DoThisPtr) (long blockAddress, long blockLength, long addrOfMasterPtr,
  178.                                      short blockType, Boolean locked, Boolean purgeable, Boolean resource);
  179.   pascal void dcmdForAllHeapBlocks (DoThisPtr DoThis);
  180.  
  181. #endif
  182.